﻿using System.ComponentModel.DataAnnotations;

namespace AiQiuQuan.Sport.Model.Models
{
    /// <summary>
    /// 活动用户新增
    /// </summary>
    public class ActivityUserAddDto : IValidatableObject
    {
        /// <summary>
        /// 活动ID
        /// </summary>
        [Required]
        public Guid ActivityId { get; set; }

        /// <summary>
        /// 活动用户
        /// </summary>
        [Required]
        [MinLength(1)]
        public List<BaseUserAddDto> UserList { get; set; }

        /// <summary>
        /// validate
        /// </summary>
        public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        {
            foreach (var item in UserList)
            {
                if (UserList.Count(m => m.ID == item.ID) >= 2)
                {
                    yield return new ValidationResult("报名用户重复");
                    yield break;
                }
            }
        }
    }
}
